package com.upcode.weighing.vo.req.pc;

import lombok.Data;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;


public class EtcIssueExpressReportReqVo2 extends EtcIssueExpressReportReqVo implements Serializable {

   /* // 追缴名单生成时间(yyyy-MM-dd HH:mm:ss)
    private String  fromStr;

    // 追缴名单生成时间(yyyy-MM-dd HH:mm:ss)
    private String  toStr;
    
    private Integer peridType;

	*//**
	 * 1-OBU邮寄时间 2-开卡时间 3-申请时间 4-二发时间 5-激活时间
	 *//*
	private Integer timeType = 1;
    
    
    public String validate() {
    	
    	if(peridType == null) {
    		return "统计时段不能为空";
    	}
    	
    	if(peridType != 1 && peridType != 2 && peridType != 3 && peridType != 4) {
    		return "统计时段不正确";
    	}
    	
    	if(peridType == 1) {
    		if(fromStr == null || fromStr.trim().isEmpty()) {
    			return "开始时间不能为空";
    		}
    		
    		try {
    			super.setFrom(LocalDateTime.parse(fromStr, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    		}catch (Exception e) {
				return "开始时间格式错误";
			}
    		
    		if(fromStr == null || fromStr.trim().isEmpty()) {
    			return "结束时间不能为空";
    		}
    		
    		try {
    			super.setTo(LocalDateTime.parse(toStr, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    		}catch (Exception e) {
				return "结束时间格式错误";
			}
    		
    	}else if(peridType == 2) {
    		if(fromStr == null || fromStr.trim().isEmpty()) {
    			return "时间不能为空";
    		}
    		LocalDate queryDate = null;
    		try { 
    			queryDate = LocalDate.parse(fromStr+"-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    		}catch (Exception e) {
				return "时间格式错误";
			}
    		super.setFrom(LocalDateTime.of(queryDate, LocalTime.MIN));
    		
    		queryDate = queryDate.with(TemporalAdjusters.lastDayOfMonth());
    		super.setTo(LocalDateTime.of(queryDate, LocalTime.MAX));
    	}else if(peridType == 3) {
    		if(fromStr == null || fromStr.trim().isEmpty()) {
    			return "时间不能为空";
    		}
    		LocalDate queryDate = null;
    		try { 
    			queryDate = LocalDate.parse(fromStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    		}catch (Exception e) {
				return "时间格式错误";
			}
    		super.setFrom(LocalDateTime.of(queryDate, LocalTime.MIN));
    		super.setTo(LocalDateTime.of(queryDate, LocalTime.MAX));
    	}else if(peridType == 4){
    		LocalDate now = LocalDate.now();
    		super.setTo(LocalDateTime.of(now, LocalTime.MAX));
    		
    		now = now.minusWeeks(1);
    		super.setFrom(LocalDateTime.of(now, LocalTime.MIN));
    	}
    	
    	
    	return null;
    }*/


}
